/*
 * rel_fmt.java
 *
 * Created on 20 de Dezembro de 2008, 11:34
 */

package relatorios;




import java.text.SimpleDateFormat;
import java.util.HashMap;
import javax.swing.JFormattedTextField;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.MaskFormatter;
import javax.swing.text.PlainDocument;
import net.sf.jasperreports.engine.JRResultSetDataSource;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;

import utilitarios.conexao;


/**
 *
 * @author  Shinigami
 */
public class rel_logs extends javax.swing.JFrame {
    
    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");  
    conexao con_pesq;
    MaskFormatter formatodata;
    int rel = 5;//rel = 0 --> data
                //rel = 1 --> nome da máquina
                //rel = 2 --> setor
                //rel = 3 --> tipo do Problema
                
    
    /** Creates new form rel_fmt */
    public rel_logs() {
        initComponents();
     
    con_pesq = new conexao();
    con_pesq.conecta();
        
    jp_data.setVisible(false);
    jp_sm.setVisible(false);

    
    
    }

    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btg_cons = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        rb_vso = new javax.swing.JRadioButton();
        rb_tudo = new javax.swing.JRadioButton();
        rb_setor = new javax.swing.JRadioButton();
        jRadioButton1 = new javax.swing.JRadioButton();
        bt_impr = new javax.swing.JButton();
        bt_sair = new javax.swing.JButton();
        jp_data = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        try
        {
            formatodata = new MaskFormatter("##/##/####");
        }   
        catch(Exception erro)
        {
            JOptionPane.showMessageDialog(null, "Não foi possível setar a máscara"+erro);
        }
        tf_datde = new JFormattedTextField(formatodata);
        jLabel4 = new javax.swing.JLabel();
        try
        {
            formatodata = new MaskFormatter("##/##/####");
        }   
        catch(Exception erro)
        {
            JOptionPane.showMessageDialog(null, "Não foi possível setar a máscara"+erro);
        }
        tf_datate = new JFormattedTextField(formatodata);
        jp_sm = new javax.swing.JPanel();
        tf_cons = tf_cons = new JTextField();
        tf_cons.setDocument( new PlainDocument()  
            {  
                @Override  
                public void insertString( int offs, String str, AttributeSet a )  
                throws BadLocationException  
                {  
                    super.insertString( offs, str.toUpperCase(), a );  
                }  
            } );  ;
            lb_sm = new javax.swing.JLabel();
            jMenuBar1 = new javax.swing.JMenuBar();
            m_arquivo = new javax.swing.JMenu();
            jm_imp = new javax.swing.JMenuItem();
            jSeparator1 = new javax.swing.JSeparator();
            jMenuItem1 = new javax.swing.JMenuItem();

            setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            setTitle("Gerar Relatório de Entradas e Saídas de Ferramentas");
            setResizable(false);

            jLabel1.setText("Selecione a consulta que deseja fazer para gerar o relatório:");

            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N

            btg_cons.add(rb_vso);
            rb_vso.setText("Tipo de Transação");
            rb_vso.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
            rb_vso.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rb_vsoActionPerformed(evt);
                }
            });

            btg_cons.add(rb_tudo);
            rb_tudo.setText("Data");
            rb_tudo.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
            rb_tudo.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rb_tudoActionPerformed(evt);
                }
            });

            btg_cons.add(rb_setor);
            rb_setor.setText("Usuário");
            rb_setor.setMargin(new java.awt.Insets(2, 0, 2, 2));
            rb_setor.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    rb_setorActionPerformed(evt);
                }
            });

            btg_cons.add(jRadioButton1);
            jRadioButton1.setText("Tipo de Ferramenta");
            jRadioButton1.setMargin(new java.awt.Insets(2, 1, 2, 2));
            jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jRadioButton1ActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(rb_tudo)
                        .addComponent(rb_vso, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                        .addComponent(jRadioButton1)
                        .addComponent(rb_setor, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap())
            );
            jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addComponent(rb_tudo)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(rb_setor, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 3, Short.MAX_VALUE)
                    .addComponent(rb_vso)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jRadioButton1))
            );

            bt_impr.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/printer.png"))); // NOI18N
            bt_impr.setToolTipText("Imprimir");
            bt_impr.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    bt_imprActionPerformed(evt);
                }
            });

            bt_sair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/window-close.png"))); // NOI18N
            bt_sair.setToolTipText("Sair");
            bt_sair.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    bt_sairActionPerformed(evt);
                }
            });

            jp_data.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N

            jLabel3.setText("De:");

            jLabel4.setText("até:");

            tf_datate.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    tf_datateActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout jp_dataLayout = new javax.swing.GroupLayout(jp_data);
            jp_data.setLayout(jp_dataLayout);
            jp_dataLayout.setHorizontalGroup(
                jp_dataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jp_dataLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel3)
                    .addGap(1, 1, 1)
                    .addComponent(tf_datde, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(jLabel4)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(tf_datate, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(56, Short.MAX_VALUE))
            );
            jp_dataLayout.setVerticalGroup(
                jp_dataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jp_dataLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(tf_datde, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tf_datate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            );

            jp_sm.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 0, 0))); // NOI18N

            tf_cons.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    tf_consActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout jp_smLayout = new javax.swing.GroupLayout(jp_sm);
            jp_sm.setLayout(jp_smLayout);
            jp_smLayout.setHorizontalGroup(
                jp_smLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jp_smLayout.createSequentialGroup()
                    .addGroup(jp_smLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(tf_cons, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(lb_sm, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(41, Short.MAX_VALUE))
            );
            jp_smLayout.setVerticalGroup(
                jp_smLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jp_smLayout.createSequentialGroup()
                    .addComponent(lb_sm, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(tf_cons, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
            );

            m_arquivo.setText("Arquivo");

            jm_imp.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F6, 0));
            jm_imp.setText("Imprimir");
            jm_imp.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jm_impActionPerformed(evt);
                }
            });
            m_arquivo.add(jm_imp);
            m_arquivo.add(jSeparator1);

            jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F12, 0));
            jMenuItem1.setText("Sair");
            m_arquivo.add(jMenuItem1);

            jMenuBar1.add(m_arquivo);

            setJMenuBar(jMenuBar1);

            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jp_data, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                            .addComponent(bt_impr, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(bt_sair, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGroup(layout.createSequentialGroup()
                                    .addGap(6, 6, 6)
                                    .addComponent(jp_sm, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                        .addComponent(jLabel1))
                    .addContainerGap(14, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel1)
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jp_data, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jp_sm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(bt_impr, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(bt_sair, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );

            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-517)/2, (screenSize.height-285)/2, 517, 285);
        }// </editor-fold>//GEN-END:initComponents

private void rb_tudoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_tudoActionPerformed
    
    jp_sm.setVisible(false);
    jp_data.setVisible(true);
    tf_cons.setText("");
    tf_datde.setText("");
    tf_datate.setText("");
    tf_datde.requestFocus();
    
    
    rel = 0;
}//GEN-LAST:event_rb_tudoActionPerformed

private void rb_vsoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_vsoActionPerformed
    
    jp_sm.setVisible(true);
    jp_data.setVisible(true);
    lb_sm.setText("Digite o tipo de transação à procurar:");
    tf_cons.setText("");
    tf_datde.setText("");
    tf_datate.setText("");
    tf_datde.requestFocus();
    
    rel = 1;
    
}//GEN-LAST:event_rb_vsoActionPerformed

private void bt_imprActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_imprActionPerformed

   if(rel == 0)//data
    {    
        
        try
            {
                if(tf_datde.getText().equals("  /  /    "))
                {
                    JOptionPane.showMessageDialog(null, "Digite a data inicial da pesquisa");
                    tf_datde.requestFocus();
                    return;
                }   
                 if(tf_datate.getText().equals("  /  /    "))
                {
                    JOptionPane.showMessageDialog(null, "Digite a data final da pesquisa");
                    tf_datate.requestFocus();
                    return;
                                   
                }
                     
                java.sql.Date datde = new java.sql.Date(format.parse(tf_datde.getText()).getTime()); 
                java.sql.Date datate = new java.sql.Date(format.parse(tf_datate.getText()).getTime()); 
                
                con_pesq.executasql("select * from log_ferramentas where data between '"+datde+"' and '"+datate+"'");
                con_pesq.resultset.beforeFirst();
                JRResultSetDataSource jrrs = new JRResultSetDataSource(con_pesq.resultset);
                JasperPrint jspimp = JasperFillManager.fillReport("relatórios/rel_logf.jasper", new HashMap(),jrrs);
                JasperViewer.viewReport(jspimp,false);

            }
            catch(Exception erro)
            {
                JOptionPane.showMessageDialog(null, "erro ="+erro);
            }     
    }
    
    if(rel == 1)//por tipo de transação
    {
        
        try
            {
                if(tf_datde.getText().equals("  /  /    "))
                {
                    JOptionPane.showMessageDialog(null, "Digite a data inicial da pesquisa");
                    tf_datde.requestFocus();
                    return;
                }   
                 if(tf_datate.getText().equals("  /  /    "))
                {
                    JOptionPane.showMessageDialog(null, "Digite a data final da pesquisa");
                    tf_datate.requestFocus();
                    return;
                                   
                }
                if(tf_cons.getText().equals(""))
                {
                    JOptionPane.showMessageDialog(null, "Digite todo ou parte do nome do tipo da transação");
                    tf_cons.requestFocus();
                    return;
                                   
                }
            
                java.sql.Date datde = new java.sql.Date(format.parse(tf_datde.getText()).getTime()); 
                java.sql.Date datate = new java.sql.Date(format.parse(tf_datate.getText()).getTime()); 
                    
                con_pesq.executasql("select * from log_ferramentas where tipotr like'"+tf_cons.getText()+"%' and  data between '"+datde+"' and '"+datate+"'");
                con_pesq.resultset.beforeFirst();
                JRResultSetDataSource jrrs = new JRResultSetDataSource(con_pesq.resultset);
                JasperPrint jspimp = JasperFillManager.fillReport("relatórios/rel_logf.jasper", new HashMap(),jrrs);
                JasperViewer.viewReport(jspimp,false);
                            
            
            }
            catch(Exception erro)
            {
                JOptionPane.showMessageDialog(null, "erro ="+erro);
            }
    }
   
    if(rel == 2)//Usuário
    {
       
    try
        {
               
        
            if(tf_datde.getText().equals("  /  /    "))
                {
                    JOptionPane.showMessageDialog(null, "Digite a data inicial da pesquisa");
                    tf_datde.requestFocus();
                    return;
                }   
                 if(tf_datate.getText().equals("  /  /    "))
                {
                    JOptionPane.showMessageDialog(null, "Digite a data final da pesquisa");
                    tf_datate.requestFocus();
                    return;
                                   
                }
                if(tf_cons.getText().equals(""))
                {
                    JOptionPane.showMessageDialog(null, "Digite todo ou parte do nome do setor");
                    tf_cons.requestFocus();
                    return;
                                   
                }
            
                 java.sql.Date datde = new java.sql.Date(format.parse(tf_datde.getText()).getTime()); 
                java.sql.Date datate = new java.sql.Date(format.parse(tf_datate.getText()).getTime()); 
                    
                con_pesq.executasql("select * from log_ferramentas where usuario like'"+tf_cons.getText()+"%' and  data between '"+datde+"' and '"+datate+"'");
                con_pesq.resultset.beforeFirst();
                JRResultSetDataSource jrrs = new JRResultSetDataSource(con_pesq.resultset);
                JasperPrint jspimp = JasperFillManager.fillReport("relatórios/rel_logf.jasper", new HashMap(),jrrs);
                JasperViewer.viewReport(jspimp,false);
            
                
            
        }
        catch(Exception erro)
        {
            JOptionPane.showMessageDialog(null, "erro ="+erro);
        } 
    }
    
    if(rel == 3)//Tipo de Ferramenta
    {
       
    try
        {
                
                if(tf_datde.getText().equals("  /  /    "))
                {
                    JOptionPane.showMessageDialog(null, "Digite a data inicial da pesquisa");
                    tf_datde.requestFocus();
                    return;
                }   
                 if(tf_datate.getText().equals("  /  /    "))
                {
                    JOptionPane.showMessageDialog(null, "Digite a data final da pesquisa");
                    tf_datate.requestFocus();
                    return;
                                   
                }
                if(tf_cons.getText().equals(""))
                {
                    JOptionPane.showMessageDialog(null, "Digite todo ou parte do nome do tipo do problema");
                    tf_cons.requestFocus();
                    return;
                                   
                }
                
                 java.sql.Date datde = new java.sql.Date(format.parse(tf_datde.getText()).getTime()); 
                java.sql.Date datate = new java.sql.Date(format.parse(tf_datate.getText()).getTime()); 
                    
                con_pesq.executasql("select * from log_ferramentas where tipofer like'"+tf_cons.getText()+"%' and  data between '"+datde+"' and '"+datate+"'");
                con_pesq.resultset.beforeFirst();
                JRResultSetDataSource jrrs = new JRResultSetDataSource(con_pesq.resultset);
                JasperPrint jspimp = JasperFillManager.fillReport("relatórios/rel_logf.jasper", new HashMap(),jrrs);
                JasperViewer.viewReport(jspimp,false);
            
                
            
        }
        catch(Exception erro)
        {
            JOptionPane.showMessageDialog(null, "erro ="+erro);
        } 
    }
    
    tf_cons.setText("");
}//GEN-LAST:event_bt_imprActionPerformed
   



private void bt_sairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_sairActionPerformed

    setVisible(false);
    
}//GEN-LAST:event_bt_sairActionPerformed

private void tf_consActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_consActionPerformed

    bt_imprActionPerformed(evt);
    
}//GEN-LAST:event_tf_consActionPerformed

private void rb_setorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_setorActionPerformed

    jp_sm.setVisible(true);
    jp_data.setVisible(true);
    lb_sm.setText("Digite o nome do usuário à procurar:");
    tf_cons.setText("");
    tf_datde.setText("");
    tf_datate.setText("");
    tf_datde.requestFocus();
    
    
    rel = 2;
    
}//GEN-LAST:event_rb_setorActionPerformed

private void jm_impActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_impActionPerformed

  bt_imprActionPerformed(evt);   
    
}//GEN-LAST:event_jm_impActionPerformed

private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed

    jp_sm.setVisible(true);
    jp_data.setVisible(true);
    lb_sm.setText("Digite o tipo de ferramenta a procurar:");
    tf_cons.setText("");
    tf_datde.setText("");
    tf_datate.setText("");
    tf_datde.requestFocus();
    
    
    rel = 3;   
    
}//GEN-LAST:event_jRadioButton1ActionPerformed

private void tf_datateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_datateActionPerformed

    if(rel == 0)
    {
    bt_imprActionPerformed(evt);
    }
    
}//GEN-LAST:event_tf_datateActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new rel_logs().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bt_impr;
    private javax.swing.JButton bt_sair;
    private javax.swing.ButtonGroup btg_cons;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JMenuItem jm_imp;
    private javax.swing.JPanel jp_data;
    private javax.swing.JPanel jp_sm;
    private javax.swing.JLabel lb_sm;
    private javax.swing.JMenu m_arquivo;
    private javax.swing.JRadioButton rb_setor;
    private javax.swing.JRadioButton rb_tudo;
    private javax.swing.JRadioButton rb_vso;
    private javax.swing.JTextField tf_cons;
    private javax.swing.JFormattedTextField tf_datate;
    private javax.swing.JFormattedTextField tf_datde;
    // End of variables declaration//GEN-END:variables

}
